package xna.android.Telas;

import xna.android.Sprite;
import xna.android.SpriteFont;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.MotionEvent;
import android.view.SurfaceView;
import br.com.R;

public class Intro extends SurfaceView
{
	private SpriteFont spriteFont;
	private Sprite exit;
	private Sprite game;
	private Sprite credits; 
	
	public Intro(Context Content)
	{
		super(Content);
		this.spriteFont = new SpriteFont(BitmapFactory.decodeResource(getResources(), R.drawable.fonte_verde));
		
		this.game = new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.btn_game), 150, 250, null, null);
		this.credits = new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.btn_credits), 145, 285, null, null);
		this.exit = new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.btn_exit), 150, 320, null, null);
	}
	
	public void Update()
	{
	}
	
	public Sprite getExit() {
		return exit;
	}
	public Sprite getGame() {
		return game;
	}
	public Sprite getCredits() {
		return credits;
	}

	public void Draw(Canvas spriteBatch)
	{
		spriteBatch.drawColor(Color.BLACK);
		spriteFont.drawString(spriteBatch, "GALAXY DEFENSE", 100, 200);
		game.draw(spriteBatch);
		credits.draw(spriteBatch);
		exit.draw(spriteBatch);
	}

	public boolean onTouchEvent(MotionEvent event) {
		
		if (event.getAction() == MotionEvent.ACTION_DOWN)
		{
			game.handleActionDown((int)event.getX(), (int)event.getY());
			credits.handleActionDown((int)event.getX(), (int)event.getY());
			exit.handleActionDown((int)event.getX(), (int)event.getY());
		}
		
		if (event.getAction() == MotionEvent.ACTION_UP)
		{
			if (game.isTouched())
				game.setTouched(false);
			if (credits.isTouched())
				credits.setTouched(false);
			if (exit.isTouched())
				exit.setTouched(false);
		}
		
		return true;
	}

}
